<template>
  <div class="my">
    <div class="my-bg">
      <img src="/images/mytopbg.png" alt="" />
    </div>
    <div class="login">
      <div v-if="loginStatus" class="login-actore">
        <img :src="userInfo.avatar" alt="" />
        <div class="actore-name">{{ userInfo.nickName }}</div>
      </div>
      <div v-else class="login-actore">
        <div class="actore-name" @click="goLogin">登录/注册</div>
      </div>
      <div class="loginvip">
        <img src="/images/mytoprember.png" alt="" />
      </div>
    </div>
    <section>
      <ul>
        <li>地址管理</li>
        <li v-if="loginStatus" @click="signOut">退出登录</li>
      </ul>
    </section>
  </div>
</template>

<script setup>
import { useRouter } from 'vue-router'
import { useUserStore } from '@/stores'
import { computed } from 'vue'
let router = useRouter()
const userStore = useUserStore()
const userInfo = computed(() => userStore.userInfo)
const loginStatus = computed(() => userStore.loginStatus)
const goLogin = () => {
  router.push({ path: '/login' })
}
const signOut = () => {
  userStore.loginOut()
  router.push({ path: '/' })
}
</script>

<style scoped>
.my {
  background-color: #f1f1f1;
  width: 100%;
  min-height: 100vh;
}

.my .my-bg {
  width: 100%;
  height: auto;
}

.my-bg img {
  width: 100%;
  height: auto;
}

.login {
  position: relative;
  width: 93%;
  height: 4rem;
  background-color: #fff;
  color: red;
  text-align: center;
  /* 文字也居中 */
  margin: -1.25rem auto;
  /* 水平居中 */
  border-radius: 0.1875rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  overflow: hidden;
  box-sizing: border-box;
}

.login-actore {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  width: 100%;
  height: 2.5rem;
}
.login-actore img {
  width: 50px;
  height: 50px;
  align-self: center;
}

.actore-name {
  text-align: center;
  line-height: 1rem;
  margin: 2px;
}

.loginvip {
  width: 100%;
  height: 1.375rem;
}

.loginvip img {
  width: 100%;
  height: 100%;
}

.my section {
  position: relative;
  top: 1.25rem;
  width: 93%;
  background-color: #fff;
  margin: 0.3125rem auto;
  line-height: 1.5rem;
  font-size: 0.4375rem;
  border-radius: 0.1875rem;
}
.my section ul {
  padding-left: 10px;
}

.my section ul li {
  background-color: #fff;
  border-bottom: 1px solid #e5e5e5;
}
</style>
